package com.test;

import com.fullstuck.dao.impl.UserDaoImpl;
import com.fullstuck.dao.User;
import com.fullstuck.service.UserService;
import com.fullstuck.service.impl.StudentServiceimpl;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.io.File;

public class test01 {
    public static void main(String[] args) {
        //读取核心xml 文件
        ClassPathXmlApplicationContext app = new ClassPathXmlApplicationContext("applicationContext.xml");
        //读取指定id 在.xml中配置的类的id值
        UserService userdao = (UserService) app.getBean("userservice");
        //读取指定方法  speak() 为方法的名字
        userdao.eat();
    }


    @Test
    public void test_scope(){
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        User userdao1 = (User)context.getBean("userdao");

        User userdao2 = (User)context.getBean("userdaoby_nostaticfactory");

        System.out.println(userdao2);


    }

    @Test
    public void test_student(){
        ClassPathXmlApplicationContext context1 = new ClassPathXmlApplicationContext("applicationContext.xml");
        StudentServiceimpl studentserviceimpl = (StudentServiceimpl) context1.getBean("studentserviceimpl");
        studentserviceimpl.dostudy();

    }
}
